<?php

namespace App\Console\Commands;

use App\Models\Config;
use App\Models\DepartmentData;
use App\Services\SmsService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class SyncDwRelation extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'sync_dw_relation';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '初始化单位的关系';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $rows = DB::table('department_datas')->get();
        foreach($rows as $row) {
            $dwmc = $row->bz_dwmc;

            DB::table('department_datas')->where('id', $row->id)->update([
                'bz_is_online' => 1,
                'dj_dwmc' => $dwmc."党委",
                'dj_dwdm' => DepartmentData::generateDwdm(),
                'dj_is_online' => 1,
            ]);
        }
        
    }

    private function dwRelations()
    {
        
    }
}
